import axios from '@/utils/request'
import {
  IDepartmentRule,
  ILoginRule,
  IPasswordRule,
  IUserRule,
} from './types/rule'

export function getPasswordRule() {
  return axios<IPasswordRule>({
    url: '/api/identity/setting/password',
    method: 'get',
  })
}

export function setPasswordRule(data: IPasswordRule) {
  return axios<IPasswordRule>({
    url: '/api/identity/setting/password',
    method: 'put',
    data,
  })
}

export function getLoginRule() {
  return axios<ILoginRule>({
    url: '/api/identity/setting/lockout',
    method: 'get',
  })
}

export function setLoginRule(data: ILoginRule) {
  return axios<ILoginRule>({
    url: '/api/identity/setting/lockout',
    method: 'put',
    data,
  })
}

export function getDepartmentRule() {
  return axios<IDepartmentRule>({
    url: '/api/identity/setting/organization-unit',
    method: 'get',
  })
}

export function setDepartmentRule(data: IDepartmentRule) {
  return axios<IDepartmentRule>({
    url: '/api/identity/setting/organization-unit',
    method: 'put',
    data,
  })
}

export function getUserRule() {
  return axios<IUserRule>({
    url: '/api/identity/setting/user',
    method: 'get',
  })
}

export function setUserRule(data: IUserRule) {
  return axios<IUserRule>({
    url: '/api/identity/setting/user',
    method: 'put',
    data,
  })
}
